/***********************************************************
* 
*     File Name:  rrworker.cpp
* 
*        Author:  Algolc
* 
*          mail:  17360224@qq.com
* 
*  Created Time:  Wed 11 Jul 2018 02:07:26 PM CST
* 
***********************************************************/

#include "zhelpers.h"
#include <unistd.h>
int main() {
    void* context = zmq_ctx_new();
    //用来和客户端交流的套接字
    void* responder = zmq_socket(context, ZMQ_REP);
    zmq_connect(responder, "tcp://localhost:5560");
    
    while(1) {
        //等待来自客户端的下一个请求:
        char* tmp_str = s_recv(responder);
        printf("Received request:[%s]\n", tmp_str);
        free(tmp_str);

        sleep(1);

        //将应答发回到客户端
        s_send(responder, "World!");
    }

    zmq_close(responder);
    zmq_ctx_destroy(context);
    return 0;
}
